home *** CD-ROM | disk | FTP | other *** search
/ The CICA Windows Explosion! / The CICA Windows Explosion! - Disc 2.iso / nt / gr564s.zip / SRC / RCSTEST < prev    next >
Text File  |  1992-09-05  |  11KB  |  450 lines

  1. #!/bin/sh
  2.  
  3. # Test RCS's functions.
  4. # The RCS commands are searched for in the PATH as usual;
  5. # to test the working directory's commands, prepend . to your PATH.
  6.  
  7. # Test RCS by creating files RCS/a.* and RCS/a.c.
  8. # If all goes well, output nothing, and remove the temporary files.
  9. # Otherwise, send a message to standard output.
  10. # Exit status is 0 if OK, 1 if an RCS bug is found, and 2 if scaffolding fails.
  11. # With the -v option, output more debugging info.
  12.  
  13. # If diff outputs `No differences encountered' when comparing identical files,
  14. # then rcstest may also output these noise lines; ignore them.
  15.  
  16. # The current directory and ./RCS must be readable, writable, and searchable.
  17.  
  18. #    $Id: rcstest,v 5.10 1992/07/28 16:12:44 eggert Exp $
  19.  
  20.  
  21. #    Copyright 1990, 1991, 1992 by Paul Eggert
  22. #    Distributed under license by the Free Software Foundation, Inc.
  23. #
  24. # This file is part of RCS.
  25. #
  26. # RCS is free software; you can redistribute it and/or modify
  27. # it under the terms of the GNU General Public License as published by
  28. # the Free Software Foundation; either version 2, or (at your option)
  29. # any later version.
  30. #
  31. # RCS is distributed in the hope that it will be useful,
  32. # but WITHOUT ANY WARRANTY; without even the implied warranty of
  33. # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
  34. # GNU General Public License for more details.
  35. #
  36. # You should have received a copy of the GNU General Public License
  37. # along with RCS; see the file COPYING.  If not, write to
  38. # the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA.
  39. #
  40. # Report problems and direct all questions to:
  41. #
  42. #     rcs-bugs@cs.purdue.edu
  43.  
  44. RCSINIT=-x
  45. export RCSINIT
  46.  
  47. SLASH=/
  48. RCSfile=RCS${SLASH}a.c
  49. RCS_alt=RCS${SLASH}a.d
  50. lockfile=RCS${SLASH}a._
  51.  
  52. case $1 in
  53. -v) q=; set -x;;
  54. '') q=-q;;
  55. *) echo >&2 "$0: usage: $0 [-v]"; exit 2
  56. esac
  57.  
  58. if test -d RCS
  59. then rmdir=:
  60. else rmdir=rmdir; mkdir RCS || exit
  61. fi
  62.  
  63. rm -f a.* $RCSfile $RCS_alt $lockfile &&
  64. echo 1.1 >a.11 &&
  65. echo 1.1.1.1 >a.3x1 &&
  66. echo 1.2 >a.12 || { echo "#initialization failed"; exit 2; }
  67.  
  68. case `diff -c a.11 a.3x1` in
  69. *!\ 1.1.1.1)
  70.     diff='diff -c';;
  71. *)
  72.     echo "#warning: diff -c does not work, so diagnostics may be cryptic"
  73.     diff=diff
  74. esac
  75.  
  76. rcs -i -L -ta.11 $q a.c &&
  77. <$RCSfile || {
  78.     echo "#rcs -i -L failed; perhaps RCS is not properly installed."
  79.     exit 1
  80. }
  81.  
  82. rlog a.c >/dev/null || { echo "#rlog failed on empty RCS file"; exit 1; }
  83. rm -f $RCSfile || exit 2
  84.  
  85. cp a.11 a.c &&
  86. ci -ta.11 -mm $q a.c &&
  87. <$RCSfile &&
  88. rcs -L $q a.c || { echo "#ci+rcs -L failed"; exit 1; }
  89. test ! -f a.c || { echo "#ci did not remove working file"; exit 1; }
  90. for l in '' '-l'
  91. do
  92.     co $l $q a.c &&
  93.     test -f a.c || { echo '#co' $l did not create working file; exit 1; }
  94.     $diff a.11 a.c || { echo '#ci' followed by co $l is not a no-op; exit 1; }
  95. done
  96.  
  97. cp a.12 a.c &&
  98. ci -mm $q a.c &&
  99. co $q a.c &&
  100. $diff a.12 a.c || { echo "#ci+co failed"; exit 1; }
  101.  
  102. rm -f a.c &&
  103. co -r1.1 $q a.c &&
  104. $diff a.11 a.c || { echo "#can't retrieve first revision"; exit 1; }
  105.  
  106. rm -f a.c &&
  107. cp a.3x1 a.c &&
  108. ci -r1.1.1 -mm $q a.c &&
  109. co -r1.1.1.1 $q a.c &&
  110. $diff a.3x1 a.c || { echo "#branches failed"; exit 1; }
  111.  
  112. rm -f a.c &&
  113. co -l $q a.c &&
  114. ci -f -mm $q a.c &&
  115. co -r1.3 $q a.c &&
  116. $diff a.12 a.c || { echo "#(co -l; ci -f) failed"; exit 1; }
  117.  
  118. rm -f a.c &&
  119. co -l $q a.c &&
  120. echo 1.4 >a.c &&
  121. ci -l -mm $q a.c &&
  122. echo error >a.c &&
  123. ci -mm $q a.c || { echo "#ci -l failed"; exit 1; }
  124.  
  125. rm -f a.c &&
  126. co -l $q a.c &&
  127. echo 1.5 >a.c &&
  128. ci -u -mm $q a.c &&
  129. <a.c || { echo "#ci -u didn't create a working file"; exit 1; }
  130. rm -f a.c &&
  131. echo error >a.c || exit 2
  132. ci -mm $q a.c 2>/dev/null && { echo "#ci -u didn't unlock the file"; exit 1; }
  133.  
  134. rm -f a.c &&
  135. rcs -l $q a.c &&
  136. co -u $q a.c || { echo "#rcs -l + co -u failed"; exit 1; }
  137. rm -f a.c &&
  138. echo error >a.c || exit 2
  139. ci -mm $q a.c 2>/dev/null && { echo "#co -u didn't unlock the file"; exit 1; }
  140.  
  141. rm -f a.c &&
  142. cp a.11 a.c &&
  143. co -f $q a.c || { echo "#co -f failed"; exit 1; }
  144. $diff a.11 a.c >/dev/null && { echo "#co -f had no effect"; exit 1; }
  145.  
  146. co -p1.1 $q a.c >a.t &&
  147. $diff a.11 a.t || { echo "#co -p failed"; exit 1; }
  148.  
  149. for n in n N
  150. do
  151.     rm -f a.c &&
  152.     co -l $q a.c &&
  153.     echo $n >a.$n &&
  154.     cp a.$n a.c &&
  155.     ci -${n}n -mm $q a.c &&
  156.     co -rn $q a.c &&
  157.     $diff a.$n a.c || { echo "#ci -$n failed"; exit 1; }
  158. done
  159.  
  160. case $LOGNAME in
  161. ?*) me=$LOGNAME;;
  162. *)
  163.     case $USER in
  164.     ?*) me=$USER;;
  165.     *)
  166.         me=`who am i` || exit 2
  167.         me=`echo "$me" | sed -e 's/ .*//' -e 's/.*!//'`
  168.         case $me in
  169.         '') echo >&2 "$0: cannot deduce user name"; exit 2
  170.         esac
  171.     esac
  172. esac
  173. date=`date -u 2>/dev/null` ||
  174. date=`TZ=GMT0 date 2>/dev/null` ||
  175. date=`TZ= date` || exit 2
  176. set $date
  177. case $2 in
  178. Jan) m=01;; Feb) m=02;; Mar) m=03;; Apr) m=04;; May) m=05;; Jun) m=06;;
  179. Jul) m=07;; Aug) m=08;; Sep) m=09;; Oct) m=10;; Nov) m=11;; Dec) m=12;;
  180. *) echo >&2 "$0: $2: unknown month name"; exit 2
  181. esac
  182. case $3 in
  183. ?) d=0$3;;
  184. *) d=$3
  185. esac
  186. case $6 in
  187. [0-9][0-9][0-9][0-9]*) D=$6/$m/$d;;
  188. *)
  189.     case $5 in
  190.     [0-9][0-9][0-9][0-9]*) D=$5/$m/$d;;
  191.     *) echo >&2 "$0: bad date format: $date"; exit 2
  192.     esac
  193. esac
  194. T=$4
  195. PWD=`pwd` && export PWD &&
  196. rm -f a.c &&
  197. co -l $q a.c &&
  198. sed 's/@/$/g' >a.kv <<EOF
  199. @Author: w @
  200. @Date: $D $T @
  201. @Header: $PWD$SLASH$RCSfile 2.1 $D $T w s @
  202. @Id: a.c 2.1 $D $T w s @
  203. @Locker:  @
  204. @Log: a.c @
  205.  * Revision 2.1  $D  $T  w
  206.  * m
  207.  *
  208. @RCSfile: a.c @
  209. @Revision: 2.1 @
  210. @Source: $PWD$SLASH$RCSfile @
  211. @State: s @
  212. EOF
  213. test $? = 0 &&
  214. sed 's/:.*\$/$/' a.kv >a.k &&
  215. sed -e 's/w s [$]/w s '"$me"' $/' -e 's/[$]Locker: /&'"$me/" a.kv >a.kvl &&
  216. sed -e '/^\$/!d' -e 's/\$$/: old $/' a.k >a.o &&
  217. sed -e 's/\$[^ ]*: //' -e 's/ \$//' a.kv >a.v &&
  218. cp a.o a.c &&
  219. ci -d"$D $T" -ss -ww -u2.1 -mm $q a.c &&
  220. $diff a.kv a.c || { echo "#keyword expansion failed"; exit 1; }
  221. co -p -ko $q a.c >a.oo &&
  222. $diff a.o a.oo || { echo "#co -p -ko failed"; exit 1; }
  223. cp a.kv a.o || exit 2
  224. rcs -o2.1 $q a.c &&
  225. rcs -l $q a.c &&
  226. ci -k -u $q a.c &&
  227. $diff a.kv a.c || { echo "#ci -k failed"; exit 1; }
  228. sed '/^[^$]/d' a.kv >a.i &&
  229. ident a.c >a.i1 &&
  230. sed -e 1d -e 's/^[     ]*//' a.i1 >a.i2 &&
  231. $diff a.i a.i2 || { echo "#ident failed"; exit 1; }
  232.  
  233. rcs -i $q a.c 2>/dev/null && { echo "#rcs -i permitted existing file"; exit 1; }
  234.  
  235. rm -f a.c &&
  236. co -l $q a.c &&
  237. echo 2.2 >a.c &&
  238. ci -mm $q a.c &&
  239. echo 1.1.1.2 >a.c &&
  240. rcs -l1.1.1 $q a.c &&
  241. ci -r1.1.1.2 -mm $q a.c &&
  242. rcs -b1.1.1 $q a.c &&
  243. test " `co -p $q a.c`" = ' 1.1.1.2' || { echo "#rcs -b1.1.1 failed"; exit 1; }
  244. rcs -b $q a.c &&
  245. test " `co -p $q a.c`" = ' 2.2' || { echo "#rcs -b failed"; exit 1; }
  246.  
  247. echo 2.3 >a.c || exit 2
  248. rcs -U $q a.c || { echo "#rcs -U failed"; exit 1; }
  249. ci -mm $q a.c || { echo "#rcs -U didn't unset strict locking"; exit 1; }
  250. rcs -L $q a.c || { echo "#rcs -L failed"; exit 1; }
  251. echo error >a.c || exit 2
  252. ci -mm $q a.c 2>/dev/null && { echo "#ci retest failed"; exit 1; }
  253.  
  254. rm -f a.c &&
  255. log0=`rlog -h a.c` &&
  256. co -l $q a.c &&
  257. ci -mm $q a.c &&
  258. log1=`rlog -h a.c` &&
  259. test " $log0" = " $log1" || { echo "#unchanged ci didn't revert"; exit 1; }
  260.  
  261. rm -f a.c &&
  262. rcs -nN:1.1 $q a.c &&
  263. co -rN $q a.c &&
  264. $diff a.11 a.c || { echo "#rcs -n failed"; exit 1; }
  265.  
  266. rm -f a.c &&
  267. rcs -NN:2.1 $q a.c &&
  268. co -rN $q a.c &&
  269. $diff a.kv a.c || { echo "#rcs -N failed"; exit 1; }
  270.  
  271. rm -f a.c &&
  272. co -l $q a.c &&
  273. rcs -c':::' $q a.c &&
  274. echo '$''Log$' >a.c &&
  275. ci -u -mm $q a.c &&
  276. test " `sed '$!d' a.c`" = ' :::' || { echo "#rcs -c failed"; exit 1; }
  277.  
  278. rm -f a.c &&
  279. rcs -o2.2: $q a.c &&
  280. co $q a.c &&
  281. $diff a.kv a.c || { echo "#rcs -o failed"; exit 1; }
  282.  
  283. rcsdiff -r1.1 -r2.1 $q a.c >a.0
  284. case $? in
  285. 1) ;;
  286. *) echo "#rcsdiff bad status"; exit 1
  287. esac
  288. diff a.11 a.kv >a.1
  289. $diff a.0 a.1 || { echo "#rcsdiff failed"; exit 1; }
  290.  
  291. rcs -l2.1 $q a.c || { echo "#rcs -l2.1 failed"; exit 1; }
  292. for i in k kv kvl o v
  293. do
  294.     rm -f a.c &&
  295.     cp a.$i a.c &&
  296.     rcsdiff -k$i $q a.c || { echo "#rcsdiff -k$i failed"; exit 1; }
  297. done
  298. co -p1.1 -ko $q a.c >a.t &&
  299. $diff a.11 a.t || { echo "#co -p1.1 -ko failed"; exit 1; }
  300. rcs -u2.1 $q a.c || { echo "#rcs -u2.1 failed"; exit 1; }
  301.  
  302. rm -f a.c &&
  303. rcsclean $q a.c &&
  304. rcsclean -u $q a.c || { echo "#rcsclean botched a nonexistent file"; exit 1; }
  305.  
  306. rm -f a.c &&
  307. co $q a.c &&
  308. rcsclean -n $q a.c &&
  309. rcsclean -n -u $q a.c &&
  310. test -f a.c || { echo "#rcsclean -n removed a file"; exit 1; }
  311.  
  312. rm -f a.c &&
  313. co $q a.c &&
  314. rcsclean $q a.c &&
  315. test ! -f a.c || { echo "#rcsclean missed an unlocked file"; exit 1; }
  316.  
  317. rm -f a.c &&
  318. co -l $q a.c &&
  319. rcsclean $q a.c &&
  320. test -f a.c || { echo "#rcsclean removed a locked file"; exit 1; }
  321. rcsclean -u $q a.c &&
  322. test ! -f a.c || {
  323.     echo "#rcsclean -u missed an unchanged locked file"; exit 1;
  324. }
  325.  
  326. rm -f a.c &&
  327. co -l $q a.c &&
  328. echo change >>a.c &&
  329. rcsclean $q a.c &&
  330. rcsclean $q -u a.c &&
  331. test -f a.c || { echo "#rcsclean removed a changed file"; exit 1; }
  332.  
  333. rm -f a.c &&
  334. co -l $q a.c &&
  335. cat >a.c <<'EOF'
  336. 2.2
  337. a
  338. b
  339. c
  340. d
  341. EOF
  342. test $? = 0 &&
  343. ci -l -mm $q a.c &&
  344. co -p2.2 $q a.c | sed -e s/2.2/2.3/ -e s/b/b1/ >a.c &&
  345. ci -l -mm $q a.c &&
  346. co -p2.2 $q a.c | sed -e s/2.2/new/ -e s/d/d1/ >a.c || exit 2
  347. cat >a.0 <<'EOF'
  348. 2.3
  349. a
  350. b1
  351. c
  352. d1
  353. EOF
  354. cat >a.1 <<'EOF'
  355. <<<<<<< a.c
  356. new
  357. =======
  358. 2.3
  359. >>>>>>> 2.3
  360. a
  361. b1
  362. c
  363. d1
  364. EOF
  365. rcsmerge -r2.2 -r2.3 $q a.c
  366. case $? in
  367. 0)
  368.     if $diff a.0 a.c >/dev/null
  369.     then echo "#warning: diff3 -E does not work, " \
  370.         "so merge and rcsmerge ignore overlaps and suppress overlap lines."
  371.     else
  372.         $diff a.1 a.c || { echo "#rcsmerge failed (status 0)"; exit 1; }
  373.         echo "#warning: The diff3 lib program exit status ignores overlaps," \
  374.             "so rcsmerge does not warn about overlap lines that it generates."
  375.     fi
  376.     ;;
  377. 1)
  378.     $diff a.1 a.c || { echo "#rcsmerge failed (status 1)"; exit 1; }
  379.     ;;
  380. *)
  381.     echo "#rcsmerge bad status"; exit 1
  382. esac
  383.  
  384. # Avoid `tr' if possible; it's not standardized well.
  385. # Our substitute merely inverts the top bit; this is just as good.
  386. cat >a.c <<'EOF'
  387. #include <stdio.h>
  388. int main() {
  389.     int c;
  390.     while ((c=getchar()) != EOF)
  391.         putchar(c ^ 0200);
  392.     return 0;
  393. }
  394. EOF
  395. if (cc a.c && test -s a.out && ./a.out <a.c) >/dev/null 2>&1
  396. then tr=./a.out
  397. else tr=tr
  398. fi
  399. {
  400.     co -p $q a.c | $tr '\012' '\200' >a.24 &&
  401.     cp a.24 a.c &&
  402.     ciOut=`(ci -l -mm $q a.c 2>&1)` &&
  403.     case $ciOut in
  404.     ?*) echo >&2 "$ciOut"
  405.     esac &&
  406.     co -p $q a.c | $tr '\200' '\012' >a.c &&
  407.     rcsdiff -r2.3 $q a.c >/dev/null &&
  408.  
  409.     echo 2.5 >a.c &&
  410.     ci -l -mm $q a.c &&
  411.     cp a.24 a.c &&
  412.     rcsdiff -r2.4 $q a.c >/dev/null
  413. } || echo "#warning: Traditional diff is used, so RCS is limited to text files."
  414.  
  415. rcs -u -o2.4: $q a.c || { echo "#rcs -u -o failed"; exit 1; }
  416.  
  417. rcs -i -Aa.c -t- $q a.d || { echo "#rcs -i -A failed"; exit 1; }
  418.  
  419. rlog -r2.1 a.c >a.t &&
  420. grep '^checked in with -k' a.t >/dev/null &&
  421. sed '/^checked in with -k/d' a.t >a.u &&
  422. $diff - a.u <<EOF
  423.  
  424. RCS file: $RCSfile
  425. Working file: a.c
  426. head: 2.3
  427. branch:
  428. locks: strict
  429. access list:
  430. symbolic names:
  431.     N: 2.1
  432.     n: 1.8
  433. comment leader: ":::"
  434. keyword substitution: kv
  435. total revisions: 13;    selected revisions: 1
  436. description:
  437. 1.1
  438. ----------------------------
  439. revision 2.1
  440. date: $D $T;  author: w;  state: s;  lines: +13 -1
  441. =============================================================================
  442. EOF
  443. test $? = 0 || { echo "#rlog failed"; exit 1; }
  444.  
  445.  
  446. test ! -f $lockfile || { echo "#lock file not removed"; exit 1; }
  447.  
  448. rm -f a.* $RCSfile $RCS_alt
  449. $rmdir RCS
  450.